#include "bs_pool.h"
#include "bs_mmap.h"

bs_pool_t* bs_pool_create(size_t size, size_t esize){
    bs_pool_t* pool = (bs_pool_t*)malloc(sizeof(bs_pool_t));
    if(pool != NULL){
        pool->size = size;
        pool->esize = esize;
        pool->mem_size = size*(esize+sizeof(_pool_head_t));

        if(bs_pool_init(pool) != BS_SUCCESS){
            return NULL;
        }
    }

    return pool;
}

int bs_pool_init(bs_pool_t* pool){
    int         i;
    //_pool_head_t*       cur;
    //_pool_head_t*       prev;
    //_pool_head_t*       next;

    pool->mem = bs_mmap_create(pool->mem_size);
    if(pool->mem == NULL){
        return BS_NOMEM;
    }

    //cur = (_pool_head_t*)pool->mem;
    for(i=0; i<pool->size; i++){
    }

    return BS_SUCCESS;
}

void* bs_pool_malloc(bs_pool_t* pool);
void bs_pool_free(void* mem);
int bs_pool_destroy(bs_pool_t* pool);
